import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_splash_screen/flutter_splash_screen.dart';
import 'package:flutter_app1/util/app_manager.dart';
import 'package:flutter_app1/navigator/tab_navigater.dart';

void main() {
  runApp(const MyApp());
  // 安卓系统设置沉浸式状态栏
  if (Platform.isAndroid) {
    SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(statusBarColor: Colors.transparent));
  }
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    // 隐藏启动屏幕
    hideSplashScreen();
    // 初始化存储库
    AppManager.init();
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: TabNavigator(),
    );
  }

  /// 隐藏启动屏幕
  Future<void> hideSplashScreen() async {
    // 延迟 隐藏启动白屏
    Future.delayed(Duration(milliseconds: 2000), () => FlutterSplashScreen.hide());
  }
}